<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>杨辉三角</title>
</head>
<body>
    <div style="text-align:center;">   
        <script>
            var shu =prompt("请输入一个小于20的整数");
            function jiecheng(num){
                var result = 1;
                for(var i = 1;i<=num;i++){
                    result =result*i;
                }
                return result;
            }
            function pailie(m,n){
                var res = jiecheng(m)/(jiecheng(n)*jiecheng(m-n));
                return res;
            }
            
            for(var i = 0;i<=shu;i++){
                for(var j =0;j<=i;j++){

                    document.write(pailie(i,j)+",");
                }
                document.write("<br>");
            }
        </script>
    </div>
    
    
    
    
    
    
    
</body>
</html>